package com.smart.five.ioc.injection.parameter.parent;

import com.smart.five.ioc.injection.parameter.Boss;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @author junrui.wang
 * @create 2018/6/6
 */
public class Test {
    public static void main(String[] args) {
        //父容器
        ApplicationContext pac = new ClassPathXmlApplicationContext(new String[]{"com/smart/five/ioc/injection/parameter/parent/beans1.xml"});

        //子容器, 指定pac为父容器
        ApplicationContext cac = new ClassPathXmlApplicationContext(new String[]{"com/smart/five/ioc/injection/parameter/parent/beans2.xml"}, pac);

        Boss boss1 = (Boss)cac.getBean("boss1");
        boss1.getCar().introduce();

        Boss boss2 = (Boss)cac.getBean("boss2");
        boss2.getCar().introduce();
    }
}
